﻿var map;

function initialize() {
    var mapOptions = {
        zoom: 19,
        center: new google.maps.LatLng(42.488353, 26.503455),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById('map'),
        mapOptions);

    var marker = new google.maps.Marker({
        position: map.getCenter(),
        map: map,
        title: 'Виж по точно!'
    });

    google.maps.event.addListener(map, 'center_changed', function () {
        window.setTimeout(function () {
            map.panTo(marker.getPosition());
        }, 300);
    });

    google.maps.event.addListener(marker, 'click', function () {
        map.setZoom(19);
        map.setCenter(marker.getPosition());
    });
}

google.maps.event.addDomListener(window, 'load', initialize());